<!DOCTYPE html>
<html lang="en">

	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>{% block title %} Dashboard - Ace Admin{% endblock %}</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
{#		<link rel="stylesheet" href="/static/css/bootstrap.min.css" />#}
		<link rel="stylesheet" href="/static/font-awesome/4.5.0/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/static/css/fonts.googleapis.com.css" />

		<link rel="stylesheet" href="/static/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
			<link rel="stylesheet" href="/static/css/ace-part2.min.css" class="ace-main-stylesheet" />

		<link rel="stylesheet" href="/static/css/ace-skins.min.css" />
		<link rel="stylesheet" href="/static/css/ace-rtl.min.css" />

		  <link rel="stylesheet" href="/static/css/ace-ie.min.css" />
    {% block styles %}<!--custom styles-->{% endblock %}

	</head>

	<body class="no-skin">
		<div id="navbar" class="navbar navbar-default          ace-save-state">
			<div class="navbar-container ace-save-state" id="navbar-container">
				<button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
					<span class="sr-only">Toggle sidebar</span>

					<span class="icon-bar"></span>

					<span class="icon-bar"></span>

					<span class="icon-bar"></span>
				</button>

				<div class="navbar-header pull-left">
                    <a href="{% url "index" %}" class="navbar-brand">
						<small>
							<i class="fa fa-leaf"></i>
							运维管理后台
						</small>
					</a>
				</div>

                <div class="navbar-buttons navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
                        <li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
{#								<img class="nav-user-photo" src="../assets/avatars/user.jpg" alt="Jason's Photo" />#}
								<span class="user-info">
									<small>Welcome,</small>
									{{ user }}
								</span>

								<i class="ace-icon fa fa-caret-down"></i>
							</a>

							<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
								<li>
									<a href="#">
										<i class="ace-icon fa fa-cog"></i>
										Settings
									</a>
								</li>

								<li>
									<a href="profile.html">
										<i class="ace-icon fa fa-user"></i>
										Profile
									</a>
								</li>

								<li class="divider"></li>

								<li>
									<a href="{% url 'logout' %}">
										<i class="ace-icon fa fa-power-off"></i>
                                            注销登录
									</a>
								</li>
							</ul>
						</li>
                    </ul>
                </div>


				
			</div><!-- /.navbar-container -->
		</div>

		<div class="main-container ace-save-state" id="main-container">
			<script type="text/javascript">
				try{ace.settings.loadState('main-container')}catch(e){}
			</script>

			<div id="sidebar" class="sidebar                  responsive                    ace-save-state">
				<script type="text/javascript">
					try{ace.settings.loadState('sidebar')}catch(e){}
				</script>

				<div class="sidebar-shortcuts" id="sidebar-shortcuts">
					<div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
						<button class="btn btn-success">
							<i class="ace-icon fa fa-signal"></i>
						</button>

						<button class="btn btn-info">
							<i class="ace-icon fa fa-pencil"></i>
						</button>

						<button class="btn btn-warning">
							<i class="ace-icon fa fa-users"></i>
						</button>

						<button class="btn btn-danger">
							<i class="ace-icon fa fa-cogs"></i>
						</button>
					</div>

					<div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
						<span class="btn btn-success"></span>

						<span class="btn btn-info"></span>

						<span class="btn btn-warning"></span>

						<span class="btn btn-danger"></span>
					</div>
				</div><!-- /.sidebar-shortcuts -->
                {%  block leftbar %}
                        <div id="leftbar">

                            </div>

{#                 {% include "cmdb/navbar.html" %}#}
                {% endblock %}
				<div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
					<i id="sidebar-toggle-icon" class="ace-icon fa fa-angle-double-left ace-save-state" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
				</div>
			</div>

			<div class="main-content">
				<div class="main-content-inner">
					<div class="breadcrumbs ace-save-state" id="breadcrumbs">
					{% block breadcrumb  %}
						<ul class="breadcrumb">
							<li>
								<i class="ace-icon fa fa-home home-icon"></i>
								<a href="#">Home</a>
							</li>
							<li class="active">Dashboard</li>
						</ul><!-- /.breadcrumb -->
					{% endblock %}
						<div class="nav-search" id="nav-search">
							<form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="ace-icon fa fa-search nav-search-icon"></i>
								</span>
							</form>
						</div><!-- /.nav-search -->
					</div>

					<div class="page-content">
						<div class="ace-settings-container" id="ace-settings-container">
							<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
								<i class="ace-icon fa fa-cog bigger-130"></i>
							</div>

							<div class="ace-settings-box clearfix" id="ace-settings-box">
								<div class="pull-left width-50">
									<div class="ace-settings-item">
										<div class="pull-left">
											<select id="skin-colorpicker" class="hide">
												<option data-skin="no-skin" value="#438EB9">#438EB9</option>
												<option data-skin="skin-1" value="#222A2D">#222A2D</option>
												<option data-skin="skin-2" value="#C6487E">#C6487E</option>
												<option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
											</select>
										</div>
										<span>&nbsp; Choose Skin</span>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2 ace-save-state" id="ace-settings-navbar" autocomplete="off" />
										<label class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2 ace-save-state" id="ace-settings-sidebar" autocomplete="off" />
										<label class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2 ace-save-state" id="ace-settings-breadcrumbs" autocomplete="off" />
										<label class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" autocomplete="off" />
										<label class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2 ace-save-state" id="ace-settings-add-container" autocomplete="off" />
										<label class="lbl" for="ace-settings-add-container">
											Inside
											<b>.container</b>
										</label>
									</div>
								</div><!-- /.pull-left -->

								<div class="pull-left width-50">
									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover" autocomplete="off" />
										<label class="lbl" for="ace-settings-hover"> Submenu on Hover</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact" autocomplete="off" />
										<label class="lbl" for="ace-settings-compact"> Compact Sidebar</label>
									</div>

									<div class="ace-settings-item">
										<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight" autocomplete="off" />
										<label class="lbl" for="ace-settings-highlight"> Alt. Active Item</label>
									</div>
								</div><!-- /.pull-left -->
							</div><!-- /.ace-settings-box -->
						</div><!-- /.ace-settings-container -->
						{% block page-header %}
						<div class="page-header">
							<h1>
								Dashboard
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									overview &amp; stats
								</small>
							</h1>
						</div><!-- /.page-header -->
						{% endblock %}
						<div class="row">
                            {% block content  %}
								dashboard
                            {% endblock %}
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

			

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->


		<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="/static/js/ace-extra.min.js"></script>

		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='/static/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
            <script src="//cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="/static/js/excanvas.min.js"></script>
		<![endif]-->
		<script type="text/javascript" src="/static/js/jquery-ui.custom.min.js"></script>
		<script  type="text/javascript" src="/static/js/jquery.ui.touch-punch.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery.easypiechart.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery.sparkline.index.min.js"></script>
         <script  type="text/javascript" src="/static/js/date.format.js"></script>
		<!-- ace scripts -->
		<script type="text/javascript" src="/static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="/static/js/ace.min.js"></script>
		<script type="text/javascript" src="/static/js/bootstrap-paginator.js"></script>
        <script type="text/javascript"  src="/static/js/layer.js"></script>

		<!-- inline scripts related to this page -->
        <script>

        window.setInterval(refresh, 1000);
    function refresh() {
        var r = new Date().getTime() + Math.random() + Math.random();
        $("a").each(function () {
            var v = $(this).attr("href");
            if (v != undefined) {
                if (v.indexOf("?")>0) {
                    if (v.indexOf("r=")>0) {
                        var idxr = v.indexOf("r=");
                        v = v.substring(0,idxr-1);
                        if(v.indexOf("?")<=0){
                            v = v +"?";
                        }
                        $(this).attr("href", v + "&r=" + r);
                    } else {
                        $(this).attr("href", v + "&r=" + r);
                    }

                } else {
                    $(this).attr("href", v + "?r=" + r);
                }
            }

        });
    }

    //自动生成菜单相关函数
   $(document).ready(function () {
       var url="{% url "user_menu" %}";
        $.ajax(
                {
                    type: "POST",
                    url:url,
                    data: {csrfmiddlewaretoken:"{{csrf_token}}"},
                    dataType: "json",
                     success: function(ret){
                          var html = '<ul class="nav nav-list"> <li class="active"><a href="{% url "index" %}"> <i class="menu-icon fa fa-tachometer"></i> <span class="menu-text"> Dashboard </span> </a> <b class="arrow"></b> </li>';

                         for(var i=0,l=ret.length;i<l;i++){

                                html+='<li class=""><a href="#" class="dropdown-toggle"><i class="menu-icon fa fa-desktop"></i><span class="menu-text">'+ret[i]['name']+'</span><b class="arrow fa fa-angle-down"></b> </a> <b class="arrow"></b><ul class="submenu">'
                             var urllist=ret[i]['list'];
                             for (var j=0,q=urllist.length;j<q;j++){
                                    html+='<li class=""><a href="/'+urllist[j]['url_name']+'"><i class="menu-icon fa fa-caret-right"></i>'+urllist[j]['name']+'</a> <b class="arrow"></b> </li>'
                                }
                                html+=' </ul></li>'

                            }
                         html+='</ul>';
{#                         alert(html);#}
                         //console.log(html);
                        $("#leftbar").html(html)
                     },
                     error: function (msg) {
                          alert("Connect Error");
                    }
                }
                  )
   });



    function getCookie(name){
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");

    if(arr=document.cookie.match(reg))

        return unescape(arr[2]);
    else
        return null;
}

function setCookie(name,value)
{
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}




function ajax_get(url,sid,isresult,tdlocation,postdata,action){
    $.ajax({
            type: "POST",
            url:url,
           data: postdata,
            dataType: "json",

           beforeSend:function(XMLHttpRequest){
               $("#mytable").find("tr").each(function() {
                    var tdArr = $(this).children();
                    selectid=tdArr.eq(1).html(); //判断ID是否相同,相同则自动修改 td result的显示
                    if(sid==selectid){
                         prestring="正在执行:[ "+action+" ],请等待....";
                        tdArr.eq(tdlocation).html(prestring);} //请求之前清空td array 数值
                    });
          $("#loading").html("<img src='/static/images/loading-1.gif' />"); //在后台返回success之前显示loading图标

     	},
            timeout:300000,
            success: function(ret){
                $("#loading").empty(); //ajax返回成功，清除loading图标
                if(isresult==0){         //判断是否添加到表格
                    $("#mytable").find("tr").each(function() {
                    var tdArr = $(this).children();
                    selectid=tdArr.eq(1).html(); //判断ID是否相同,相同则自动修改 td result的显示

                    if(sid==selectid){
                        tdArr.eq(tdlocation).html(ret.msg);}
                    });

                }else {
                    alert(ret.msg);
                }
            },
                error: function (msg) {
                    $("#mytable").find("tr").each(function() {
                    var tdArr = $(this).children();
                    selectid=tdArr.eq(1).html(); //判断ID是否相同,相同则自动修改 td result的显示
                    if(sid==selectid){
                        failedstring="执行:[ "+action+" ]操作失败....";
                        tdArr.eq(tdlocation).html('<p style="color:red;font-size:9px ">'+failedstring+'</p>');}
                    });
                     }
    });
}




{#$(function () {#}
{#            $.ajaxSetup({#}
{#                layerIndex:-1,#}
{#                beforeSend: function () {#}
{#                    this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });#}
{#                },#}
{#                complete: function () {#}
{#                    layer.close(this.layerIndex);#}
{#                },#}
{#                error: function () {#}
{#                    layer.alert('部分数据加载失败，可能会导致页面显示异常，请刷新后重试', {#}
{#                        skin: 'layui-layer-molv'#}
{#                       , closeBtn: 0#}
{#                       , shift: 4 //动画类型#}
{#                    });#}
{#                }#}
{#            });#}
{#        });#}

   </script>
    {% block scripts %}
<!--custom scripts-->
{% endblock %}
	</body>
</html>
